/**
 * 
 */
package cn.biplam.front.template.control.pop;

import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.html.HtmlDiv;
import cn.biplam.front.html.base.Html;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.template.Template;
import cn.biplam.front.template.control.pop.PopLevel.PopArith_Layer;

/**
 *  算术表达式弹出框
 * @author XiaoRuxing Dec 12, 200911:27:19 AM
 * @version 1.0
 */
public class PopArith implements Template{
	private String ID;
	private String sHomeUrl;
	private HtmlWindow popup;
	private FramePopArith frame;
	private String cssID="arb";
	private UserInfo mUser;

	/**
	 * 功能：构造方法
	 * @param ID		Confirm窗口绑定对象ID(外部Div)
	 * @param sHomeUrl	主页Url
	 * @param sTitle	标题
	 * @throws ErrorMessage 
	 */
	public PopArith(String ID,String sHomeUrl,UserInfo mUser,String sTitle) throws ErrorMessage{
		this.ID=ID;
		this.sHomeUrl=sHomeUrl;
		this.mUser=mUser;
		this._init(sTitle);
	}
	
	
	/**
	 * 功能：
	 * @param sTitle
	 * @throws ErrorMessage
	 */
	private void _init(String sTitle) throws ErrorMessage{
		frame=new FramePopArith(ID+"f",sHomeUrl,mUser);
	}
	
	/**
	 * 功能：向Frame正文区域放入Html对象
	 * @param html
	 * @throws ErrorMessage
	 */
	public void put(Html html) throws ErrorMessage{
		this.frame.put(html);
	}
	
	/**
	 * 功能：向Popup父容器内放入Html对象
	 * @param html
	 * @throws ErrorMessage
	 */
	public void putPopup(Html html) throws ErrorMessage{
		this.popup.put(html);
	}
	
	/**
	 * 功能：向Frame父容器放入Html对象
	 * @param html
	 * @throws ErrorMessage
	 */
	public void putFrame(Html html) throws ErrorMessage{
		this.frame.putFrame(html);
	}
	
	/**
	 * 功能：返回设置好的HtmlWindow对象
	 * @return
	 * @throws ErrorMessage 
	 */
	public HtmlWindow get() throws ErrorMessage{
		//背景层
		popup=new HtmlDiv(ID,"pp");
		popup.setZIndex(PopArith_Layer.Back.toString());//设置背景层次
		popup.put(new HtmlDiv(this.ID+"b",cssID));
		
		//内容层
		frame.setLayerIndex(PopArith_Layer.Frame);//设置内容层次
		
		/**装入设置好的Frame*/
		popup.put(frame.get());
		//设置第一次载入时显示然后隐藏
		popup.bind("$('"+this.ID+"').style.visibility='inherit';");
		popup.bind("$('"+this.ID+"').style.visibility='hidden';");
		return this.popup;
	}

	/**
	 * 设置背景cssID
	 * @param cssID
	 */
	protected void setCssID(String cssID) {
		this.cssID = cssID;
	}
	
	
}
